package com.ficus.road.maintain.core.model.coverage;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Date;

/**
 * @author xiawen yang
 * @date 2022/3/15 下午1:53
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class UnitCoverageWeekZH {

    private String managesectionid;

    private String statistype;

    private String cyclenum;

    private double worklengthall;

    private double worklength;

    private String departid;

    private double coverweek;

    public UnitCoverageWeek convert2UnitCoverage(UnitCoverageWeekZH zh, Date date) {
        return UnitCoverageWeek.builder()
                .id(zh.getManagesectionid() + zh.getDepartid() + zh.getCyclenum())
                .shouldCover(ObjectUtils.isEmpty(zh.getWorklengthall()) ? 0 : zh.getWorklengthall())
                .realCover(ObjectUtils.isEmpty(zh.getWorklength()) ? 0 : zh.getWorklength())
                .lastModificationTime(date)
                .unitId(zh.getManagesectionid())
                .cycleNum(zh.getCyclenum())
                .departId(zh.getDepartid())
                .cycleCoverage(zh.getCoverweek())
                .build();
    }
}
